<template>
  <el-dialog :visible.sync="dialogShowed" width="1200px" title="评论管理">
    <c-u-r-d-table ref="table" :option="commentOptions"/>
  </el-dialog>
</template>

<script>
import CURDTable from '@/framework/components/table/CURDTable'
import { commentApi } from '@/feature/cms/components/commentApi'
import ColumnType from '@/framework/constant/ColumnType'
import OnlineStatusEnum from '@/framework/constant/OnlineStatusEnum'

export default {
  name: 'CommentListDialog',
  components: { CURDTable },
  props: {
    showed: Boolean,
    businessId: [String, Number],
    businessType: [String, Number]
  },
  watch: {
    dialogShowed() {
      this.$emit('update:showed', this.dialogShowed)
    },
    showed() {
      this.dialogShowed = this.showed
    },
    businessId() {
      this.$refs.table.reloadTable()
    },
    businessType() {
      this.$refs.table.reloadTable()
    }
  },
  data() {
    return {
      dialogShowed: false,
      commentOptions: {
        requestApi: commentApi,
        groupId: 1,
        initListParams: () => {
          return {
            businessId: this.businessId,
            businessType: this.businessType
          }
        },
        columns: [
          // {
          //   label: '用户ID',
          //   prop: 'userId',
          //   searchable: true,
          //   type: ColumnType.SELECT
          // },
          // {
          //   label: '动态ID',
          //   prop: 'trendId',
          //   searchable: true,
          //   type: ColumnType.SELECT
          // },
          {
            label: '用户昵称',
            prop: 'user.nickName'
          },
          {
            label: '用户头像',
            prop: 'user.headImg',
            type: ColumnType.IMAGE
          },
          {
            label: '评论内容',
            searchable: true,
            prop: 'content',
            width: 300
          },
          {
            label: '点赞数',
            prop: 'likeNum',
            type: ColumnType.NUMBER
          },
          {
            label: '评论数',
            prop: 'commentNum',
            type: ColumnType.NUMBER
          },
          {
            label: '转发数',
            prop: 'transmitNum',
            type: ColumnType.NUMBER
          },
          {
            label: '状态',
            searchable: true,
            type: ColumnType.RADIO,
            hiddenInForm: true,
            options: OnlineStatusEnum,
            prop: 'status'
          },
          {
            label: '被回复用户ID',
            prop: 'replyToUserId',
            type: ColumnType.SELECT
          },
          {
            label: '创建时间',
            type: ColumnType.DATETIME,
            hiddenInForm: true,
            prop: 'gmtCreate'
          },
          {
            label: '修改时间',
            type: ColumnType.DATETIME,
            hiddenInForm: true,
            prop: 'gmtModified'
          }
        ]
      }
    }
  },
  methods: {
    handleRemoveComment({ arg, $service }) {
      $service.handleDel(arg)
    },
    handleSearchComment({ $table }) {
      $table.handleList()
    },
    handleOnlineComment({ arg, $service }) {
      $service.handleOnline(arg, '评论')
    },
    handleOfflineComment({ arg, $service }) {
      $service.handleOffline(arg, '评论')
    }
  }
}
</script>

<style scoped>

</style>
